// 封装后端的登录相关api接
import http from '../utils/http';

const BASE_URL = 'http://localhost:8082'; // 后端API地址，根据实际情况修改

export const login = async (userData) => {
  try {
    const response = await http.post('/login', userData);
    return response.data;
  } catch (error) {
    throw error;
  }
};

export const register = async (userData) => {
  try {
    // 根据接口要求构造注册数据
    const registerData = {
      username: userData.username,
      password: userData.password,
      realName: userData.realName, 
      userType: parseInt(userData.userType),
      phone: userData.phone,
      company: userData.company 
    };
    const response = await http.post('/login/register', registerData);
    return response.data;
  } catch (error) {
    throw error;
  }
}; 